package com.amkai.mobile.utils.manager;

import android.app.Activity;

import com.amkai.mobile.common.job.login.MobileLoginJob;
import com.amkai.mobile.common.job.login.MobileLoginJobResult;
import com.amkai.mobile.utils.data.Constants;
import com.amkai.mobile.utils.data.MobileDb;
import com.amkai.mobile.utils.manager.job.MobileServiceManager;

public class LoginManager {
	


	public static MobileLoginJobResult login(Activity context){
		MobileLoginJobResult jobResult = null;
		
		try {
			String username = MobileDb.getLoginParameter(context, Constants.USERNAME);
			String password = MobileDb.getLoginParameter(context, Constants.PASSWORD);
			MobileLoginJob job = MobileLoginJob.getByUsenameAndPassword(username, password);
			jobResult = MobileServiceManager.processMobileJob(context, job);
			
		} catch (Exception E) {
			E.printStackTrace();
			
		}
		return jobResult;

	}
	
	String getConnectionUrl(Activity context) {
		String result = "";
		String host = MobileDb.getLoginParameter(context,Constants.SERVER);
		if (host.length() != 0) {
			result = Constants.URLPrefix + host + Constants.URLSuffix;
		}
		return result;
	}
	
}
